//
//  WDViewChildController.m
//  Zhihuijinfu
//
//  Created by 王笛 on 2017/1/10.
//  Copyright © 2017年 王笛. All rights reserved.
//

#import "WDChildController.h"

@interface WDChildController ()

@end

@implementation WDChildController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

//设置StatusBar样式
- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    [self checkNewWorking];
    
    [self preferredStatusBarStyle];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
    //添加边缘返回手势
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
    } 
}

#pragma - mark - 设置网络状态监听
/**
 typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) {
 AFNetworkReachabilityStatusUnknown          = -1,//未识别的网络
 AFNetworkReachabilityStatusNotReachable     = 0,//不可达的网络
 AFNetworkReachabilityStatusReachableViaWWAN = 1,//2G,3G,4G...
 AFNetworkReachabilityStatusReachableViaWiFi = 2,//wifi网络
 */
- (void)checkNewWorking
{
    AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
    
    [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        
        switch (status) {
            case AFNetworkReachabilityStatusUnknown:
                
                [WDPromptBox showPromptBoxWithMassage:@"未识别的网络"];
                
                break;
                
            case AFNetworkReachabilityStatusNotReachable:
                [WDPromptBox showPromptBoxWithMassage:@"网络连接中断"];
                break;
                
            case AFNetworkReachabilityStatusReachableViaWWAN:
                
                break;
                
            case AFNetworkReachabilityStatusReachableViaWiFi:
                
                break;
            default:
                break;
        }
        
    }];
    
    //开始监听
    [manager startMonitoring];
    
}

//加载占位图
- (WDPlaceholderView *)loadPlaceViewWithImageName:(NSString *)imageName status:(NSString *)status
{
    WDPlaceholderView *placeView = [WDPlaceholderView placeholderViewWithImageName:imageName status:status];
    [self.view addSubview:placeView];
    placeView.backgroundColor = WDBackColor;
    placeView.hidden = NO;
    
    [placeView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(100);
        make.left.equalTo(25);
        make.right.equalTo(-25);
        make.bottom.equalTo(0);
    }];
    
    return placeView;
}

//移除占位图
- (void)hideLoadView
{
    self.placeView.hidden = YES;
}

//改变展位图
- (void)showPlaceViewWithImageName:(NSString *)imageName status:(NSString *)status
{
    self.placeView.hidden = NO;
    
    self.placeView.imageName = imageName;
    
    self.placeView.status = status;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
